5.1.1 Define operator (unary and binary), identifier, operand, actual
parameter (argument), formal parameter, infix notation, postfix
notation and prefix notation.

Identifier:
An identifier referencing a variable can be used to access the variable in order to read out the value, or alter the value, or edit the attributes of the variable, such as access permission, locks, semaphores, etc.

For instance, a variable might be referenced by the identifier "total_count" and the variable can contain the number 1956. If the same variable is referenced by the identifier "x" as well, and if using this identifier "x", the value of the variable is altered to 2009, then reading the value using the identifier "total_count", the result is 2009 and not 1956.

If a variable is only referenced by a single identifier, that can simply be called the name of the variable. Otherwise, we can speak of one of the names of the variable. For instance, in the previous example, the "total_count" is a name of the variable in question, and "x" is another name of the same variable.

http://en.wikipedia.org/wiki/Variable_%28computer_science%29#Identifiers_referencing_a_variable

Operand:


In mathematics, an operand is the object of a mathematical operation, a quantity on which an operation is performed. For example, + - / *.
http://en.wikipedia.org/wiki/Operand

Operator:
An Operator.
An Operator.

The value on which the Operand acts. E.g. in 3 + 4, the operators are 3 and 4.

Actual parameter(argument), Formal parameter:

When the terms formal parameter and actual parameter are used, they generally correspond with the definitions used in computer science. In the definition of a function such as f(x) = x + 2, x is a formal parameter. When the function is used as in y = f(3) + 5 or just the value of f(3), 3 is the actual parameter value that is substituted for the formal parameter in the function definition. These concepts are discussed in a more precise way in functional programming and its foundational disciplines, lambda calculus and combinatory logic. In computing, parameters are often called arguments, and the two words are used interchangeably. However, some computer languages such as C define argument to mean actual parameter (i.e., the value), and parameter to mean formal parameter.

Actual Parameter: Actual parameters (also known as arguments) are what are passed by the caller.
Formal Parameter: Formal parameters are the parameters as they are known in the function definition.

For example, in the following code, a and b are the formal parameters, and x and y are the actual parameters:

int max(int a, int b) {
if (a > b) return a;
else return b;
}
int m = max(x, y);

http://wiki.answers.com/Q/What_is_the_difference_between_actual_and_formal_parameters

Examples of Infix, prefix (Polish Notation) and postfix (reverse Polish notation) Notation

conversion.jpg

Postfix (RPN) is a mathematical notation wherein every operator follows all of its operands.

Prefix (PN) is a mathetmatical notation which places operators to the left of their operands.

Infix notation is the common arithmetic and logical formula notation, in which operators are written infix-style between the operands they act on (e.g. 2 + 2).

Conversion:


Conversion_between_prepostinfix.jpg







5.1.2 Define stack

Stack

In computer science, a stack is a last in, first out (LIFO) abstract data type and linear data structure. A stack can have any abstract data type as an element, but is characterized by two fundamental operations, called push and pop. The push operation adds a new item to the top of the stack, or initializes the stack if it is empty. If the stack is full and does not contain enough space to accept the given item, the stack is then considered to be in an overflow state. The pop operation removes an item from the top of the stack. A pop either reveals previously concealed items, or results in an empty stack, but if the stack is emexternal image 500px-Data_stack.svg.pngpty then it goes into underflow state (It means no items are present in stack to be removed).

A stack is a restricted data structure, because only a small number of operations are performed on it. The nature of the pop and push operations also means that stack elements have a natural order. Elements are removed from the stack in the reverse order to the order of their addition: therefore, the lower elements are those that have been on the stack the longest.

Extra reading:
http://www.sigcis.org/files/A%20brief%20history.pdf





5.1.3 Discuss the features and appropriate usage of stacks including:

parameter storage, interrupt handling, evaluation of arithmetic

expressions and storage of subprogram return addresses.



Storage of subprogram return addresses:
As each subroutine of a program is called the machine saves the return address of the calling routine as an element on a stack. This ensures that subroutine returns are processed in the reverse order of subroutine calls, which is the desired operation. Each time a subroutine terminates the return address of the calling routine is popped off the stack so the program can continue.
Parameter storage: Whenever a subroutine is called it is often given a set of parameters upon which to act. Those parameters are copied onto a parameter stack before performing a method call.

Interrupt handling:
When a peripheral device makes an interrupt request (IRQ), that request is pushed onto a stack. If that request is in itself interrupted by another request, the new request is pushed onto the stack. As each request is processed, it is popped off the stack so the earlier request can be processed and so on until the CPU can return to its main task.

Evaluation of arithmetic expressions:

To see why stacks are well suited to expression evaluation, consider how the following arithmetic expression would be computed:
X = (A + B) * (C + D)

First, A and B would be added together. Then, this intermediate result is pushed onto the expression evaluation stack. Next, C and D are added and the result is also pushed onto the expression evaluation stack. Finally, the top two stack elements (A+B and C+D) are multiplied and the result is stored in the variable X. The expression evaluation stack provides automatic management of intermediate results of expressions, and allows as many levels of precedence in the expression as there are available stack elements.


Define Queue:external image 500px-Data_Queue.svg.png

The general concept of a queue is very familiar – items join the queue at the back (tail) and leave the queue at the front (head). Queues are therefore FIFO structures (First in First Out) – so unlike stacks, items are dequeued (removed from the head of the queue) in the same order that they are queued (added to the tail of the queue).







5.1.4 Discuss the features and appropriate usage of queues including:

keyboard queues, print queues and customer queue simulations.


Practical applications include but are not limited to:
1) reading from the keyboard/mouse (granted the OS often does this for you)
2) printing (i.e. multiple people/jobs printing to the same printer), the OS typically has a print queue, and the printer only accepts one job at a time, but some can queue up multiple jobs to print
3) simulation programs queue up multiple messages (or items to do), in response to some stimulus (keypress, interrupt, etc.)
4) simulation programs can queue up multiple items to do at a timed interval ... a good example of this would be on the old Donkey Kong sending the barrels down the girders, etc.
5) the old Missile Command may have used queues to queue up missiles that were going to attack the ships, and then launch them at the targets during the next cycle

http://answers.yahoo.com/question/index?qid=20100306064117AA8YwBW


Print Spooler

In some situations, it might be necessary to allow the promotion of items already in the queue to the head. One such situation is a print queue (spooler). Although print jobs are usually serviced in the order in which they are sent, an urgent job can be promoted to the head of the queue for immediate printing.

Human Queues

Queues are often used in computer programs to model or simulate human queues, such as customer queues in supermarkets, patients waiting for treatment in hospitals etc. Again, in such situations it may be appropriate to over-ride the normal FIFO order, for example if an emergency case arrives at hospital and warrants immediate treatment (i.e. inserted at the head of the queue) or if the condition of a patient already in the queue deteriorates (i.e. promoted to the head of the queue)

Buffer

Queue structures are also used in buffers that temporarily store data, often to compensate for different input and processing speeds or to cope with processing being interrupted. The keyboard buffer is a classic example – as keys are struck by the user the resulting output from the keyboard is sent to a buffer before being passed on for processing. The irritating bleep you get if you repeatedly press keys is a signal that the buffer is full. Buffers by their nature tend to employ a strict FIFO order, promoting keystrokes or stored data is not usually an appropriate operation.

Define Binary Tree


In computer science, a binary tree is a tree data structure in which each node has at mostexternal image 500px-Binary_tree.svg.png two child nodes, usually distinguished as "left" and "right". Nodes with children are parent nodes, and child nodes may contain references to their parents. Outside the tree, there is often a reference to the "root" node (the ancestor of all nodes), if it exists. Any node in the data structure can be reached by starting at root node and repeatedly following references to either the left or right child.














5.1.5 Discuss the features and appropriate usage of binary trees including:

storing search keys, decision trees and file systems.


Binary Search Tree - Used in many search applications where data is constantly entering/leaving, such as the map and set objects in many languages' libraries.
Binary Space Partition - Used in almost every 3D video game to determine what objects need to be rendered.
Binary Tries - Used in almost every high-bandwidth router for storing router-tables.
Hash Trees - used in p2p programs and specialized image-signatures in which a hash needs to be verified, but the whole file is not available.
Heaps - Used in heap-sort; fast implementations of Dijkstra's algorithm; and in implementing efficient priority-queues, which are used in scheduling processes in many operating systems, Quality-of-Service in routers, and A* (path-finding algorithm used in AI applications, including video games).
Huffman Coding Tree (Chip Uni) - used in compression algorithms, such as those used by the .jpeg and .mp3 file-formats.
GGM Trees - Used in cryptographic applications to generate a tree of pseudo-random numbers.
Syntax Tree - Constructed by compilers and (implicitly) calculators to parse expressions.
Treap - Randomized data structure used in wireless networking and memory allocation.
T-tree - Though most databases use some form of B-tree to store data on the drive, databases which keep all (most) their data in memory often use T-trees to do so.